package com.dd.keel.core.common.i18n;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import com.dd.keel.core.common.utils.URLUtil;

public class PropertyMap {
	
	private Properties props = new Properties();
	private Class contextClass = null;
	
	public PropertyMap(Class contextClass)
	{
		this.contextClass = contextClass;
	}
	
	public void init(String property_file_class_path)
	{
		try {
			InputStream in = URLUtil.getURLFromClasspath(property_file_class_path, contextClass).openStream();
			props.load( in );
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public String getProperty(String key)
	{
		return props.getProperty(key);
	}
	
	public String getText(String key)
	{
		if(props.containsKey(key))
		{
			return props.getProperty(key);
		}
		return key;
	}
	
}
